﻿using System.Collections.Generic;
using System.Security.Principal;
using MiniExcelLibs.Attributes;

namespace ArcLightProtector
{
    /// <summary>
    /// 功能描述    ：SensorPoint  
    /// 创 建 者    ：石斌
    /// 创建日期    ：2024/12/25 19:46:33 
    /// </summary>
    public class SensorPointData
    {

        [ExcelColumnName("地址")]
        public string AddressHex { get; set; }

        [ExcelColumnName("名称")]
        public string Name { get; set; }

        [ExcelColumnName("数据类型")]
        public string DataType { get; set; }

        [ExcelColumnName("数据长度")]
        public ushort? Length { get; set; }

        [ExcelColumnName("控件类型")]
        public string ControlType { get; set; }

        [ExcelColumnName("单位")]
        public string Unit { get; set; }

        [ExcelColumnName("只读")]
        public bool Readonly { get; set; }


        [ExcelColumnName("最小值")]
        public int? MinValue { get; set; }

        [ExcelColumnName("最大值")]
        public int? MaxValue { get; set; }

        [ExcelColumnName("操作符")]
        public string Operator { get; set; }

        [ExcelColumnName("bit位号")]
        public int BitPosition { get; set; }

        [ExcelColumnName("操作值")]
        public int? OperationValue { get; set; }


        [ExcelColumnName("映射信息")]
        public string MapInfo { get; set; }

        /// <summary>
        /// 用于连续读取
        /// </summary>
        [ExcelColumnName("组")]
        public int? Group { get; set; }

        /// <summary>
        /// 用于字符串
        /// </summary>
        [ExcelColumnName("结束地址")]
        public string EndAddressHex { get; set; }

        public ushort Address { get; set; }

        public object Value { get; set; }
        public object RawValue { get; set; }

        public Dictionary<string, string> MapDic { get; set; }

        /// <summary>
        /// 功能名称
        /// </summary>
        public string FuncName { get; set; }

        /// <summary>
        /// 获取映射值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string GetMapValue(object key)
        {
            if (MapDic == null) return "";
            var key1 = key.ToString();
            if (MapDic.ContainsKey(key1)) return MapDic[key1];
            return "";
        }
    }
}
